import { inputconfig } from '@/api/systemconfig'
import { getfiletree } from '@/api/systemconfig'
import { setvideopath } from '@/api/systemconfig'
import { setimagepath } from '@/api/systemconfig'
import { getvideopath } from '@/api/systemconfig'
import { getimagepath } from '@/api/systemconfig'
import { getConfig, capture, saveInput, updateThreshold,
  updateDetectStatus, updateSaveStatus, updateSaveTimes, updateSource, changeInputType } from '@/api/systemconfig'
import { postPos } from '@/api/picGener'

const state = {

}

const mutations = {

}

const actions = {
  // 发送图片位置
  postPos({ commit }, param) {
    return new Promise((resolve, reject) => {
      postPos(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  // usbconfig
  inputconfig({ commit }, param) {
    // const { startData, name, endData } = param
    // const { username, password } = userInfo
    return new Promise((resolve, reject) => {
      inputconfig(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  // 发送获取目录请求
  getfiletree({ commit }, param) {
    return new Promise((resolve, reject) => {
      getfiletree(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 发送更新视频路径请求
  setvideopath({ commit }, param) {
    return new Promise((resolve, reject) => {
      setvideopath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 发送更新视频路径请求
  getvideopath({ commit }, param) {
    return new Promise((resolve, reject) => {
      getvideopath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 发送更新图片路径请求
  setimagepath({ commit }, param) {
    return new Promise((resolve, reject) => {
      setimagepath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 开始检测
  startInspec({ commit }, param) {
    return new Promise((resolve, reject) => {
      setimagepath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 停止检测
  stopInspec({ commit }, param) {
    return new Promise((resolve, reject) => {
      setimagepath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 发送更新视频路径请求
  getimagepath({ commit }, param) {
    return new Promise((resolve, reject) => {
      getimagepath(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 接受配置信息
  getConfig({ commit }) {
    return new Promise((resolve, reject) => {
      getConfig().then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 捕获图像配置信息
  capture({ commit }, param) {
    return new Promise((resolve, reject) => {
      console.log(param)
      capture(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  // 第一个保存按钮信息
  saveInput({ commit }, param) {
    return new Promise((resolve, reject) => {
      saveInput(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  updateThreshold({ commit }, param) {
    return new Promise((resolve, reject) => {
      updateThreshold(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  updateDetectStatus({ commit }, param) {
    return new Promise((resolve, reject) => {
      updateDetectStatus(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  updateSaveStatus({ commit }, param) {
    return new Promise((resolve, reject) => {
      updateSaveStatus(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  updateSaveTimes({ commit }, param) {
    return new Promise((resolve, reject) => {
      updateSaveTimes(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  updateSource({ commit }, param) {
    return new Promise((resolve, reject) => {
      updateSource(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },

  changeInputType({ commit }, param) {
    return new Promise((resolve, reject) => {
      changeInputType(param).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

